<?php

function getArrFromString($str, $type) {
  $result_array = array();
  switch ($type) {
    case "web_server" :
      $ar = split("[/ ]", $str);
      for ($i = 0; $i < (count($ar)); $i++) {
        switch (strtoupper($ar[$i])) {
          case 'APACHE':
            $i++;
            $result_array["Apache"] = $ar[$i];
            break;
          case 'PHP':
            $i++;
            $result_array["PHP"] = $ar[$i];
            break;
          case 'MOD_SSL':
            $i++;
            $result_array["MOD_SSL"] = $ar[$i];
            break;
          case 'OPENSSL':
            $i++;
            $result_array["OPENSSL"] = $ar[$i];
            break;
          case 'MOD_PERL':
            $i++;
            $result_array["MOD_PERL"] = $ar[$i];
            break;
          case 'PERL':
            $i++;
            $result_array["PERL"] = $ar[$i];
            break;          
        }
      }
      $result_array["MYSQL Client"] = mysqli_get_client_info();
  }
  return $result_array;
}

function encodeResponse($success,$response){
  return json_encode(array("success"=>$success,"response"=>$response));
}

?>
